package com.IO.IODemo01;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class A10TryCatch {
    public static void main(String[] args) {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        try {
            fis = new FileInputStream("D:\\TestFile\\Copy\\A\\test.mp4");
            fos = new FileOutputStream("D:\\TestFile\\Copy\\B\\Best.mp4");
            byte[] b = new byte[1024 * 1024 * 5];
            int n;
            while ((n = fis.read(b)) != -1) {
                fos.write(b, 0, n);
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if(fos != null){
                try {
                    fos.close();
                    
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            if(fis != null){
                try {
                    fis.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
